/*----------------------------------------------------------------------
  - File name      : STC8Ax_COMP.h
  - Author         : Quark Team
  - Update date    : 2020-12-09                  
  -	Copyright      : Gevico Electronic studio   
  - Module comments: Header file of COMP module.
-----------------------------------------------------------------------*/
#ifndef __STC8Ax_COMP_H_
#define __STC8Ax_COMP_H_
/*-----------------------------------------------------------------------
|                               INCLUDES                                |
-----------------------------------------------------------------------*/
/*--------------------------------------------------------
| @Description: STC8Ax Options                           |
--------------------------------------------------------*/
#include "STC8Ax_REG.h"   
/*--------------------------------------------------------
| @Description: STC8Ax core                              |
--------------------------------------------------------*/
#include "STC8Ax_CORE.h"
/*-----------------------------------------------------------------------
|                                 DATA                                  |
-----------------------------------------------------------------------*/

/*--------------------------------------------------------
| @Description: COMP Pin define                          |
--------------------------------------------------------*/

/* PEPin */
#define  COMP_PE_P37     0xF7

#define  COMP_PE_P10     0x00	   
#define  COMP_PE_P11     0x01
#define  COMP_PE_P12     0x02
#define  COMP_PE_P13     0x03
#define  COMP_PE_P14     0x04
#define  COMP_PE_P15     0x05
#define  COMP_PE_P16     0x06
#define  COMP_PE_P17     0x07
	   
#define	 COMP_PE_P00     0x08
#define	 COMP_PE_P01     0x09
#define	 COMP_PE_P02     0x0A
#define	 COMP_PE_P03     0x0B
#define	 COMP_PE_P04     0x0C
#define	 COMP_PE_P05     0x0D
#define	 COMP_PE_P06     0x0E

/* NEPin */
#define  COMP_NE_P36     0x10

/* 
NEPin and PEPin :
Test the internal 1.344v refv voltage.
*/
#define	 COMP_IN_REV     0x0F  

/*--------------------------------------------------------
| @Description: COMP output direction enumerator         |
--------------------------------------------------------*/

typedef enum
{
    COMP_DIR_Forward = 0, COMP_DIR_Reverse        
}   COMPDIRPut_Type;

/*--------------------------------------------------------
| @Description: COMP init structure                      |
--------------------------------------------------------*/

typedef struct
{
    uint8 PEPin;            //COMP positive input selection bit
    uint8 NEPin;	          //COMP negative input selection bit
    FUNSTATE AC_FTW;        //COMP 0.1us analog filter control bit
    uint16 DC_FTW;          //COMP digital filter clock number. 0 for off
    COMPDIRPut_Type DIRPut; //COMP output direction
    FUNSTATE Output;        //COMP result output control bit
    FUNSTATE Run;           //COMP operation control bit
}   COMP_InitType;

/*-----------------------------------------------------------------------
|                             API FUNCTION                              |
-----------------------------------------------------------------------*/

FSCSTATE COMP_Init(const COMP_InitType *COMPx);

#endif
/*-----------------------------------------------------------------------
|          END OF FLIE        (C) COPYRIGHT Gevico Electronics          | 
-----------------------------------------------------------------------*/

